; *** Towers of Hanoi
; *** Copyright 1998-2002 Zillions Development
; v.2.0

; You need to purchase Zillions of Games to load this rules file
; Visit the Zillions web site at http://www.zillions-of-games.com

(version "2.0")
(translate
 ("Towers of Hanoi 4 Disks" "汉诺塔-4块木板")
 ("Towers of Hanoi 5 Disks" "汉诺塔-5块木板")
 ("Towers of Hanoi 6 Disks" "汉诺塔-6块木板")
 ("Towers of Hanoi 7 Disks" "汉诺塔-7块木板")
)
(define try1 ((verify (empty? n)) $1 (while not-empty? n) 
   (if (on-board? s) s
     (verify (not-piece? disk1)) n)
   add))
(define try2 ((verify (empty? n)) $1 (while not-empty? n) (if (on-board? s) s
   (verify (not-piece? disk1))
   (verify (not-piece? disk2)) n) 
   add))
(define try3 ((verify (empty? n)) $1 (while not-empty? n) 
   (if (on-board? s) s
    (verify (not-piece? disk1)) 
    (verify (not-piece? disk2))
    (verify (not-piece? disk3)) n)
   add))
(define try4 ((verify (empty? n)) $1 (while not-empty? n) 
  (if (on-board? s) s
   (verify (not-piece? disk1)) 
   (verify (not-piece? disk2)) 
   (verify (not-piece? disk3))
   (verify (not-piece? disk4)) n)
   add))
(define try5 ((verify (empty? n)) $1 (while not-empty? n) 
  (if (on-board? s) s
   (verify (not-piece? disk1)) 
   (verify (not-piece? disk2)) 
   (verify (not-piece? disk3))
   (verify (not-piece? disk4))
   (verify (not-piece? disk5)) n)
  add))
(define try6 ((verify (empty? n)) $1 (while not-empty? n) 
  (if (on-board? s) s
   (verify (not-piece? disk1)) 
   (verify (not-piece? disk2)) 
   (verify (not-piece? disk3))
   (verify (not-piece? disk4))
   (verify (not-piece? disk5))
   (verify (not-piece? disk6)) n)
  add))
(define try7 ((verify (empty? n)) $1 (while not-empty? n) 
  (if (on-board? s) s
   (verify (not-piece? disk1)) 
   (verify (not-piece? disk2)) 
   (verify (not-piece? disk3))
   (verify (not-piece? disk4))
   (verify (not-piece? disk5))
   (verify (not-piece? disk6))
   (verify (not-piece? disk7)) n)
  add))

(game
  (title "Towers of Hanoi 4 Disks")
  (description "将所有的木片移到中间一根柱子。小的必须在大的上面。")
  (history "This puzzle was invented by the French mathematician Edouard Lucas in
     1883.   It was sold (in an eight-disk version) as a toy, with an account of a
     legend that there is a `Tower of Brahma` in a temple in Benares, India.   This
     tower has 64 golden disks, which the temple priests move at one disk each second.
     When they complete their task, the world will come to an end in a clap of thunder.
     This should take a little over 18 billion billion seconds.")
  (strategy "Your first objective should be to transfer the largest disk to the
     center post.  Then build up your tower upwards on disk at a time.\\
     All of the puzzles can be solved recursively: for the four-disk puzzle,
     transfer the three smallest disks to the right-hand post, then move the fourth
     disk to the center post and repeat the same pattern of moves.   In this way you
     can gradually build up to solving the seven-disk problem.\\
     With best play, the four-disk puzzle can be solved in 15 moves.")
  (option "prevent flipping" true)
  (solution "Solutions/Towers_of_Hanoi/4_disk.zsg")
  (move-sound "Audio\\Click3.wav")
  (click-sound "Audio\\Click.wav")
  (release-sound "Audio\\Click3.wav")
  (players Disk-Guy)
  (turn-order Disk-Guy)
  (board 
    (image "images\Towers_of_Hanoi\Shaag\tower.bmp" "images\Towers_of_Hanoi\tower.bmp")
    (grid
      (start-rectangle 1 1 177 34)
      (dimensions
         ("a/b/c" (177 0)) ; files
         ("0/1/2/3/4/5/6/7" (0 33)) ; ranks
     )
     (directions (n 0 -1) (s 0 1) (e 1 0) (w -1 0))
    )
   )

   (piece
      (name disk1)
      (image Disk-Guy "images\Towers_of_Hanoi\Shaag\disk1.bmp" "images\Towers_of_Hanoi\disk1.bmp")
      (description "Disk1\A disk can be moved to any pile.")
      (help "Disk: moves to any pile, but never on top of a smaller disk")
      (moves
         (try1 c7)
         (try1 b7)
		 (try1 a7)
      )
   )
   (piece
      (name disk2)
      (image Disk-Guy "images/Towers_of_Hanoi/Shaag/disk2.bmp" "images/Towers_of_Hanoi/disk2.bmp")
      (description "Disk1\A disk can be moved to any pile, but never onto a smaller disk.")
      (help "Disk: moves to any pile, but never on top of a smaller disk")
      (moves
         (try2 a7)
         (try2 b7)
		 (try2 c7)
      )
   )
   (piece
      (name disk3)
      (image Disk-Guy "images/Towers_of_Hanoi/Shaag/disk3.bmp" "images/Towers_of_Hanoi/disk3.bmp")
      (description "Disk1\A disk can be moved to any pile, but never onto a smaller disk.")
      (help "Disk: moves to any pile, but never on top of a smaller disk")
      (moves
         (try3 a7)
         (try3 b7)
		 (try3 c7)
      )
   )
   (piece
      (name disk4)
      (image Disk-Guy "images/Towers_of_Hanoi/Shaag/disk4.bmp" "images/Towers_of_Hanoi/disk4.bmp")
      (description "Disk1\A disk can be moved to any pile, but never onto a smaller disk.")
      (help "Disk: moves to any pile, but never on top of a smaller disk")
      (moves
         (try4 a7)
         (try4 b7)
		 (try4 c7)
      )
   )
   (piece
      (name disk5)
      (image Disk-Guy "images/Towers_of_Hanoi/Shaag/disk5.bmp" "images/Towers_of_Hanoi/disk5.bmp")
      (description "Disk5\A disk can be moved to any pile, but never onto a smaller disk.")
      (help "Disk: moves to any pile, but never on top of a smaller disk")
      (moves
         (try5 a7)
         (try5 b7)
		 (try5 c7)
      )
   )
   (piece
      (name disk6)
      (image Disk-Guy "images/Towers_of_Hanoi/Shaag/disk6.bmp" "images/Towers_of_Hanoi/disk6.bmp")
      (description "Disk6\A disk can be moved to any pile, but never onto a smaller disk.")
      (help "Disk: moves to any pile, but never on top of a smaller disk")
      (moves
         (try6 a7)
         (try6 b7)
		 (try6 c7)
      )
   )
   (piece
      (name disk7)
      (image Disk-Guy "images/Towers_of_Hanoi/Shaag/disk7.bmp" "images/Towers_of_Hanoi/disk7.bmp")
      (description "Disk7\A disk can be moved to any pile, but never onto a smaller disk.")
      (help "Disk: moves to any pile, but never on top of a smaller disk")
      (moves
         (try7 a7)
         (try7 b7)
		 (try7 c7)
      )
   )
   (board-setup
      (Disk-Guy
         (disk1 a4)
         (disk2 a5)
         (disk3 a6)
         (disk4 a7)
      )
   )
   (win-condition (Disk-Guy)  (and (absolute-config disk1 (b4))
                               (absolute-config disk2 (b5))
                               (absolute-config disk3 (b6))
                               (absolute-config disk4 (b7))
                          )
   )
)

(variant
  (title "Towers of Hanoi 5 Disks")
  (strategy "Your first objective should be to transfer the largest disk to the
     center post.  Then build up your tower upwards on disk at a time.\\
     All of the puzzles can be solved recursively: for the five-disk puzzle,
     transfer the four smallest disks to the right-hand post, then move the fifth
     disk to the center post and repeat the same pattern of moves.   You're working
     your way up to solving the seven-disk problem.\\
     With best play, the five-disk puzzle can be solved in 31 moves.")
  (solution "Solutions/Towers_of_Hanoi/5_disk.zsg")
  (board-setup
      (Disk-Guy
         (disk1 a3)
         (disk2 a4)
         (disk3 a5)
         (disk4 a6)
         (disk5 a7)
      )
   )
   (win-condition (Disk-Guy)  (and (absolute-config disk1 (b3))
                              (absolute-config disk2 (b4))
                              (absolute-config disk3 (b5))
                              (absolute-config disk4 (b6))
						      (absolute-config disk5 (b7))                           
                          )
   )
)

(variant
  (title "Towers of Hanoi 6 Disks")
  (strategy "Your first objective should be to transfer the largest disk to the
     center post.  Then build up your tower upwards on disk at a time.\\
     All of the puzzles can be solved recursively: for the six-disk puzzle,
     transfer the five smallest disks to the right-hand post, then move the sixth
     disk to the center post and repeat the same pattern of moves.   Now you're
     ready to tackle the seven-disk problem.\\
     With best play, the six-disk puzzle can be solved in 63 moves.")
  (solution "Solutions/Towers_of_Hanoi/6_disk.zsg")
 
  (board-setup
      (Disk-Guy
         (disk1 a2)
         (disk2 a3)
         (disk3 a4)
         (disk4 a5)
         (disk5 a6)
         (disk6 a7)
      )
   )
   (win-condition (Disk-Guy)  (and (absolute-config disk1 (b2))
                              (absolute-config disk2 (b3))
                              (absolute-config disk3 (b4))
                              (absolute-config disk4 (b5))
						      (absolute-config disk5 (b6))
                              (absolute-config disk6 (b7))
                          )
   )
)

(variant
  (title "Towers of Hanoi 7 Disks")
  (strategy "Your first objective should be to transfer the largest disk to the
     center post.  Then build up your tower upwards on disk at a time.\\
     All of the puzzles can be solved recursively: for the seven-disk puzzle,
     transfer the six smallest disks to the right-hand post, then move the seventh
     disk to the center post and repeat the same pattern of moves.\\
     With best play, the seven-disk puzzle can be solved in 127 moves.")
  (solution "Solutions/Towers_of_Hanoi/7_disk.zsg")
  (board-setup
      (Disk-Guy
         (disk1 a1)
         (disk2 a2)
         (disk3 a3)
         (disk4 a4)
         (disk5 a5)
         (disk6 a6)
		 (disk7 a7)
      )
   )
   (win-condition (Disk-Guy)  (and (absolute-config disk1 (b1))
                              (absolute-config disk2 (b2))
                              (absolute-config disk3 (b3))
                              (absolute-config disk4 (b4))
						      (absolute-config disk5 (b5))
                              (absolute-config disk6 (b6))
                              (absolute-config disk7 (b7))
                          )
   )
)
